/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.posplus.losspreventiondataimporter.service;

import com.posplus.lossprevention.APDAOFactory;
import com.posplus.lossprevention.dao.TransactionsDAO;
import com.posplus.lossprevention.mapping.Stores;
import com.posplus.lossprevention.mapping.Transactions;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author scottw
 */
public class TransactionsService {
    private TransactionsDAO transDAO;
    
    public TransactionsService(TransactionsDAO transDAO){
        this.transDAO = transDAO;
    }
    
    public TransactionsService(APDAOFactory lpDAOFactory){
        this.transDAO = lpDAOFactory.getTransactionsDAO();
    }
    
    public List<Transactions> getBetweenDate(Stores store, Calendar start, Calendar end){
        return transDAO.getByStoreBetweenDate(store, start, end);
    }

    public void bulkInsert(List<Transactions> mappedTransactions) {
        transDAO.bulkInsert(mappedTransactions);
    }

    public void saveAll(List<Transactions> mappedTransactions) {
	Iterator<Transactions> iter = mappedTransactions.iterator();
	while (iter.hasNext()) {
	    transDAO.save(iter.next());	    	    
	}
    }
}
